const nodemailer = require("nodemailer");


// create reusable transporter object using the default SMTP transport
let transporter = nodemailer.createTransport({
  host: "smtp.qq.com",
  port: 465,
  secure: true, // true for 465, false for other ports
  auth: {
    user: '2020974511@qq.com', // generated ethereal user
    pass: 'uletcmvflevgcbjc', // generated ethereal password
  },
});

function sendEmail(toUser, subject, description, content, text = '') {
  // send mail with defined transport object
  return transporter.sendMail({
    from: '2020974511@qq.com', // sender address
    to: `${toUser.email}`, // list of receivers
    subject, // Subject line
    text, // plain text body
    html: `
      <div style="">
        Hey ${toUser.nickname || toUser.email}!
        <br\><br\>
        ${description}
        <br\><br\>
        ${content}
        <!-- Verification code: 643599 -->
        <br\><br\>
        Thanks,
        <br\>
        The WcZix Team
        <br\>
      </div>
    `, // html body
  });
  // console.log("Message sent: %s", .messageId);
  // Message sent: <b658f8ca-6296-ccf4-8306-87d57a0b4321@example.com>
}

module.exports = {
  sendEmail
}